import { Component, OnInit } from '@angular/core';
import {HouseViewingApplyServiceSvr} from '../../services/houseViewingApplyServiceSvr'
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
  selector: 'app-reverse-management',
  templateUrl: './reverse-management.component.html',
  styleUrls: ['./reverse-management.component.less']
})
export class ReverseManagementComponent implements OnInit {

  constructor(
    private houseViewingApplyServiceSvr:HouseViewingApplyServiceSvr,
    private message: NzMessageService
  ) { }

  ngOnInit(): void {
    this.customerId=this.customerId.replace("\"","").replace("\"","");
    this.houseViewingApplyServiceSvr.listHouseViewingApplyByCustomerId('',this.customerId).then((res)=>{
      // console.log(res);
      this.reverseList=res._Items
      console.log(11);
      console.log(res);
      // console.log('id'+this.reverseHouseId);
    })
  }
// 预约状态
reverseState:number=1
// 用户id
customerId:any=localStorage.getItem('customerId')
// 预约列表
reverseList:any
// 预约房屋id
reverseHouseId:string=''
// 取消预约
goCancelReverse(e:any){
  console.log('id:'+e.Id);
  this.houseViewingApplyServiceSvr.deleteHouseViewingApplyByPrimaryKey('',e.Id).then((res)=>{
    console.log(res);
    if(res==1){
      // console.log('取消预约成功');
      this.message.info('取消预约成功');
      this.houseViewingApplyServiceSvr.listHouseViewingApplyByCustomerId('',this.customerId).then((res)=>{
        // console.log(res);
        this.reverseList=res._Items
      })
    }else{
      // console.log('取消预约失败');
      this.message.info('取消预约失败');
    }
  })
}
}

